home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / GRAPHIC / PPAINT.H < prev    next >
C/C++ Source or Header  |  1991-12-10  |  5KB  |  175 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Persistent graphics attributes.
  25.  */
  26.  
  27. #ifndef ppaint_h
  28. #define ppaint_h
  29.  
  30. #include <InterViews/defs.h>
  31. #include <InterViews/paint.h>
  32. #include <InterViews/Graphic/objman.h>
  33. #include <InterViews/Graphic/pfile.h>
  34. #include <InterViews/Graphic/persistent.h>
  35. #include <InterViews/Graphic/ref.h>
  36. #include <InterViews/Graphic/reflist.h>
  37.  
  38. class PColor : public Persistent {
  39. public:
  40.     PColor();
  41.     PColor(ColorIntensity r, ColorIntensity g, ColorIntensity b);
  42.     PColor(const char*);
  43.     ~PColor();
  44.  
  45.     int PixelValue ();
  46.     void Intensities(ColorIntensity& r, ColorIntensity& g, ColorIntensity& b);
  47.     boolean Valid ();
  48.     operator Color*();
  49.  
  50.     virtual ClassId GetClassId();
  51.     virtual boolean IsA(ClassId);
  52. protected:
  53.     virtual boolean read(PFile*);
  54.     virtual boolean write(PFile*);
  55. protected:
  56.     Color* value;
  57. };
  58.  
  59. class PPattern : public Persistent {
  60. public:
  61.     PPattern();
  62.     PPattern(int p[patternHeight]);
  63.     PPattern(int dither);
  64.     ~PPattern();
  65.  
  66.     operator Pattern*();
  67.  
  68.     virtual ClassId GetClassId();
  69.     virtual boolean IsA(ClassId);
  70. protected:
  71.     virtual boolean read(PFile*);
  72.     virtual boolean write(PFile*);
  73. protected:
  74.     int data [patternHeight];
  75.     Pattern* value;
  76. };
  77.  
  78. static const int NO_WIDTH = -1;
  79.  
  80. class PBrush : public Persistent {
  81. public:
  82.     PBrush();
  83.     PBrush(int p, int w = 1);
  84.     ~PBrush();
  85.  
  86.     int Width();
  87.     operator Brush*();
  88.  
  89.     virtual ClassId GetClassId();
  90.     virtual boolean IsA(ClassId);
  91. protected:
  92.     virtual boolean read(PFile*);
  93.     virtual boolean write(PFile*);
  94. protected:
  95.     int p;
  96.     Brush* value;
  97. };
  98.  
  99. class PFont : public Persistent {
  100. public:
  101.     PFont();
  102.     PFont(const char*);
  103.     PFont(const char*, int);
  104.     ~PFont();
  105.  
  106.     int Baseline();
  107.     int Height();
  108.     int Width(const char*);
  109.     int Width(const char*, int);
  110.     int Index(const char*, int offset, boolean between);
  111.     int Index(const char*, int, int offset, boolean between);
  112.  
  113.     boolean Valid();
  114.     boolean FixedWidth();
  115.     operator Font*();
  116.  
  117.     virtual ClassId GetClassId();
  118.     virtual boolean IsA(ClassId);
  119. protected:
  120.     virtual boolean read(PFile*);
  121.     virtual boolean write(PFile*);
  122. protected:
  123.     char* name;
  124.     int count;
  125.     Font* value;
  126. };
  127.  
  128. /*
  129.  * Standard attributes.  These must be initialized by calling
  130.  * InitPPaint.  If the persistence features of paints are not required,
  131.  * then InitPPaint must be called explicitly before any of the standard
  132.  * attributes are used.  Otherwise the call to InitPPaint should be
  133.  * made in the persistent object initialization routine passed to the
  134.  * object manager constructor.  See Persistent(3I) for more information.
  135.  */
  136. extern PColor* pblack;
  137. extern PColor* pwhite;
  138. extern PPattern* psolid;
  139. extern PPattern* pclear;
  140. extern PBrush* psingle;
  141. extern PFont* pstdfont;
  142. extern void InitPPaint();
  143.  
  144. /*
  145.  * inlines
  146.  */
  147.  
  148. inline int PColor::PixelValue () { return value->PixelValue(); }
  149. inline boolean PColor::Valid () { return value->Valid(); }
  150. inline PColor::operator Color* () { return value; }
  151.  
  152. inline void PColor::Intensities (
  153.     ColorIntensity& r, ColorIntensity& g, ColorIntensity& b
  154. ) {
  155.     value->Intensities(r, g, b);
  156. }
  157.  
  158. inline PPattern::operator Pattern* () { return value; }
  159.  
  160. inline int PBrush::Width () { 
  161.     return (value == nil) ? NO_WIDTH : value->Width();
  162. }
  163.  
  164. inline PBrush::operator Brush* () { return value; }
  165.  
  166. inline int PFont::Baseline () { return value->Baseline(); }
  167. inline int PFont::Height () { return value->Height(); }
  168. inline int PFont::Width (const char* s) { return value->Width(s); }
  169. inline int PFont::Width (const char* s, int len) {return value->Width(s, len);}
  170. inline boolean PFont::Valid () { return value->Valid(); }
  171. inline boolean PFont::FixedWidth () { return value->FixedWidth(); }
  172. inline PFont::operator Font* () { return value; }
  173.  
  174. #endif
  175.